//
//  HeaderSecondDetailView.m
//  bh
//
//  Created by lanou on 15/12/21.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "HeaderSecondDetailView.h"

@implementation HeaderSecondDetailView
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        _HeaderImageView = [[UIImageView alloc]initWithFrame:(CGRectMake(0, 0, kWidth, 240))];
        [self addSubview:_HeaderImageView];
        //返回上一个界面的button
        self.backButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
        self.backButton.frame = CGRectMake(10, 20, 25, 25);
        [self.backButton setImage:[[UIImage imageNamed:@"arrowdown.png"] imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)] forState:(UIControlStateNormal)];
        [self addSubview:self.backButton];
        
        _AuthorFaceView = [[UIImageView alloc]initWithFrame:(CGRectMake(kWidth/ 3 +30, 50, 60, 60))];
        _AuthorFaceView.layer.masksToBounds = YES;
        _AuthorFaceView.layer.borderWidth = 2;
        _AuthorFaceView.layer.cornerRadius = _AuthorFaceView.bounds.size.width / 2;
        _AuthorFaceView.layer.borderColor = [UIColor clearColor].CGColor;
        [_HeaderImageView addSubview:_AuthorFaceView];
        
        _AuthorNickLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, 110, kWidth, 30))];
        _AuthorNickLabel.textColor = [UIColor whiteColor];
        _AuthorNickLabel.textAlignment = NSTextAlignmentCenter;
        [_HeaderImageView addSubview:_AuthorNickLabel];
        
        _titleLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, 140, kWidth, 40))];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont systemFontOfSize:22];
        _titleLabel.textColor = [UIColor whiteColor];
        [_HeaderImageView addSubview:_titleLabel];
        
        _areaLabel = [[UILabel alloc]initWithFrame:(CGRectMake(0, 170,kWidth, 40))];
        _areaLabel.textAlignment = NSTextAlignmentCenter;
        _areaLabel.textColor = [UIColor whiteColor];
        [_HeaderImageView addSubview:_areaLabel];
        
        _likeNumberLabe = [[UILabel alloc]initWithFrame:(CGRectMake(100, 200, 40, 30))];
        _likeNumberLabe.textColor = [UIColor whiteColor];
        [_HeaderImageView addSubview:_likeNumberLabe];
        
        _comment_countLabel = [[UILabel alloc]initWithFrame:(CGRectMake(170, 200, 40, 30))];
        _comment_countLabel.textColor = [UIColor whiteColor];
        [_HeaderImageView addSubview:_comment_countLabel];
        
        _viewLabel = [[UILabel alloc]initWithFrame:(CGRectMake(220, 200, 60, 30))];
        _viewLabel.textColor = [UIColor whiteColor];
        [_HeaderImageView addSubview:_viewLabel];
        
        
        
        
        
    }
    return self;
}


- (void)setPhotos:(Photos *)photos{
    
    if (_photos != photos) {
        _photos = photos;
        
        [_HeaderImageView setImageWithURL:[NSURL URLWithString:photos.cover_pic]];
        
        _titleLabel.text = photos.title;
        _likeNumberLabe.text = photos.liked_count;
        _viewLabel.text = photos.view_count;
        _comment_countLabel.text = photos.comment_count;
        
        
        _AuthorNickLabel.text = photos.author_nick;
        [_AuthorFaceView setImageWithURL:[NSURL URLWithString:photos.author_face]];
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
